<template>
  <view class="container">
    <view class="addUrlStr" @click="addUrl">新增</view>
    <view class="info">
      <view class="item" v-for="(item,index) in scanSettingList">
        <view class="item-title">{{ item.urlStr }} </view>
        <view class="deleteButton" @click="deleteUrl(item.code)">删除</view>
      </view>
    </view>
  </view>
</template>

<script>
import {deleteScanSetting, getScanSettingList} from "@/apis/ScanSetting";

export default {
  data() {
    return {
      scanSettingList: []
    };
  },
  methods: {
    addUrl() {
      uni.navigateTo({
        url: '/pagesMine/scan/set-up-add'
      })
    },
    async deleteUrl(code) {
      console.log(code, 99999)
      await deleteScanSetting(code)
      this.scanSettingList = (await getScanSettingList()).data
    }
  },
  async mounted() {
    this.scanSettingList = (await getScanSettingList()).data;
  },
}
</script>

<style lang="less" scoped>
.dflex() {
  display: flex;
  justify-content: center;
  align-items: center;
}

.dflexsb() {
  .dflex();
  justify-content: space-between;
}

.dflexsa() {
  .dflex();
  justify-content: space-around;
}

.container {
  height: 90vh;
  width: 100%;
  font-family: PingFangSC-Semibold, PingFang SC;
  padding: 30rpx;
  box-sizing: border-box;
  overflow: hidden !important;
  background: #c8c7cc;
  color: #333;

  .addUrlStr {
    .dflex();
    display: flex;
    margin-left: 90%;
    width: 10%;
    background-color: #007aff;
    border-radius: 10rpx;
  }

  .info {
    height: 80vh;
    width: 100%;
    background-color: #F7F7F7;
    margin-top: 30rpx;

    .item {
      border-bottom: 1px solid #E7E7E7;
      justify-content: flex-start;
      display: flex;
      .item-title {
        width: 80%;
      }

      .deleteButton{
        width: 10%;
        margin-left: 10%;
      }
    }
  }
}
</style>
